apache的扩展模块安装

        这个用到了apache的扩展工具 apxs

        在使用这个功能之前,请先确认是否已经加载了 mod_so 模块,方法是:

1
/usr/local/apache2/bin/httpd -l

        在列出的内容中,如果有 mod_so 那么说明已经加载了该模块。

        下面,举个例子来演示一下,如何编译安装扩展模块,例如,我想增加 mod_status.so 这个模块

1
/usr/local/apache2/bin/apxs -i -a -c mod_status.c

        请注意,这里的mod_status.c 的路径一定要写对了,不然会报错,一般情况下,这个C文件在你的源码包下,比如:

1
/usr/local/src/httpd-2.0.59/modules/generators/mod_status.c

        编译的结果类似这样:

1
2
3
4
5
6
7
8
9
10
11
12
13
/usr/local/services/apache-2.0.59/build/libtool --silent --mode=compile gcc -prefer-pic -DAP_HAVE_DESIGNATED_INITIALIZER -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/usr/local/services/apache-2.0.59/include -I/usr/local/services/apache-2.0.59/include -I/usr/local/services/apache-2.0.59/include -c -o /root/httpd-2.0.64/modules/generators/mod_status.lo /root/httpd-2.0.64/modules/generators/mod_status.c && touch /root/httpd-2.0.64/modules/generators/mod_status.slo
/usr/local/services/apache-2.0.59/build/libtool --silent --mode=link gcc -o /root/httpd-2.0.64/modules/generators/mod_status.la -rpath /usr/local/services/apache-2.0.59/modules -module -avoid-version /root/httpd-2.0.64/modules/generators/mod_status.lo
/usr/local/services/apache-2.0.59/build/instdso.sh SH_LIBTOOL='/usr/local/services/apache-2.0.59/build/libtool' /root/httpd-2.0.64/modules/generators/mod_status.la /usr/local/services/apache-2.0.59/modules
/usr/local/services/apache-2.0.59/build/libtool --mode=install cp /root/httpd-2.0.64/modules/generators/mod_status.la /usr/local/services/apache-2.0.59/modules/
cp /root/httpd-2.0.64/modules/generators/.libs/mod_status.so /usr/local/services/apache-2.0.59/modules/mod_status.so
cp /root/httpd-2.0.64/modules/generators/.libs/mod_status.lai /usr/local/services/apache-2.0.59/modules/mod_status.la
cp /root/httpd-2.0.64/modules/generators/.libs/mod_status.a /usr/local/services/apache-2.0.59/modules/mod_status.a
ranlib /usr/local/services/apache-2.0.59/modules/mod_status.a
chmod 644 /usr/local/services/apache-2.0.59/modules/mod_status.a
PATH="$PATH:/sbin" ldconfig -n /usr/local/services/apache-2.0.59/modules
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/services/apache-2.0.59/modules

        完成后,请看提示 Libraries have been installed in: 模块就会安装到这里了。